import type { UserObjType } from '@/types/settings'
import { uniRequset } from '@/utils/request'
import type { addressType } from '@/types/settings'
export const getUserProfileApi = () => {
  return uniRequset<UserObjType>({
    url: '/user/profile/',
    method: 'GET',
  })
}

export const UpdateUserInfoApi = (data: Partial<UserObjType>) => {
  return uniRequset<UserObjType>({
    url: '/user/update_user_info/',
    method: 'PUT',
    data,
  })
}
// 修改用户信息的地址
export const UpdateAddressApi = (data: addressType) => {
  return uniRequset<addressType>({
    url: '/user/update_address/',
    method: 'PUT',
    data,
  })
}
// 修改用户收货地址
export const UpdateReceiptAddressApi = (id: number, data: addressType) => {
  return uniRequset<addressType>({
    url: `/address/update_receipt_address/${id}/`,
    method: 'PUT',
    data,
  })
}
export const getAddressListAPI = () => {
  return uniRequset<addressType[]>({
    url: '/address/get_address_list/',
    method: 'GET',
  })
}

export const createAddressApi = (data: addressType) => {
  return uniRequset<addressType[]>({
    url: '/address/create_address/',
    method: 'POST',
    data,
  })
}
export const getAddressDetailApi = (id: number) => {
  return uniRequset<addressType>({
    url: `/address/get_address_detail/${id}`,
    method: 'GET',
  })
}
export const deleteAddressApi = (id: number) => {
  return uniRequset<null>({
    url: `/address/delete_address/${id}`,
    method: 'DELETE',
  })
}
